package mt;

import java.util.Scanner;
public class meituan_0319_Main_1 {
    public static void main(String[] args) {
        Scanner cin=new Scanner(System.in);
        int n=cin.nextInt();
        int[] yuna=new int[n];
        int[] zhe=new int[n];
        for (int i = 0; i < n; i++) {
            yuna[i]=cin.nextInt();
        }
        for (int i = 0; i < n; i++) {
            zhe[i]=cin.nextInt();
        }
        int m=cin.nextInt();
        int[] man=new int[m];
        int[] jian=new int[m];
        for (int i = 0; i < m; i++) {
            man[i]=cin.nextInt();
        }
        for (int i = 0; i < m; i++) {
            jian[i]=cin.nextInt();
        }
        int zhesum=0;
        int yuansum=0;
        for (int i = 0; i < n; i++) {
            zhesum+=zhe[i];
            yuansum+=yuna[i];
            int manjianV=yuansum;
            for (int j = 0; j < m; j++) {
                if (yuansum>=man[j]){
                    //可以使用满级
                    manjianV=Math.min(yuansum-jian[j],manjianV);
                }
            }
            if (manjianV==zhesum){
                System.out.print("B");
            }else if(manjianV<zhesum){
                System.out.print("M");
            }else {
                System.out.print("Z");
            }
        }
    }
}
